package thread;

public class SingletonLazy {
    // 这个引用指向唯一实例
    private volatile static SingletonLazy instance = null;
    Object locker = new Object();

    public SingletonLazy getInstance() {
        if(instance == null) {
            synchronized (locker) {
                if (instance == null) {
                    instance = new SingletonLazy();
                }
            }
        }
        return instance;
    }

    private SingletonLazy(){};
}
